/*
 * @Author: chenr 526963089@qq.com
 * @Date: 2023-01-13 17:36:49
 * @LastEditors: chenr 526963089@qq.com
 * @LastEditTime: 2023-02-09 18:36:33
 * @Description:
 */
import Mock from 'mockjs';
import userService from './services/user';
import pageService from './services/page';

const initMock = () => {
  // 判断环境不是 prod 或者 preview 是 true 时，加载 mock 服务
  if (
    import.meta.env.VITE_NODE_ENV !== 'production' ||
    import.meta.env.VITE_APP_PREVIEW === 'true'
  ) {
    // 使用同步加载依赖
    console.log('mock mounting');
    userService();
    pageService();
    Mock.setup({
      timeout: 800, // setter delay time
    });
    console.log('mock mounted');
  }
};
export default initMock();
